package commonAdmin.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 *
 *@author Jack
 *2016年1月30日下午8:40:20
 */
public class ObjectUtil {
	/**
	 * 返回小写的类名
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public static String lowerSimpleClassName(Class klass) {
		if (klass == null)
			return "";
		return klass.getSimpleName().toLowerCase();
	}

	/**
	 * 获取泛化的类型信息
	 * @param klass
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public static Type[] getParameterizedType(Class klass) {
		ParameterizedType parameterizedType = (ParameterizedType) klass.getGenericSuperclass();
		Type[] ts = parameterizedType.getActualTypeArguments();
		return ts;
	}

	public static boolean isPrimitiveOrPrimitiveWrapperOrString(Class<?> type) {
		return (type.isPrimitive() && type != void.class) || type == Double.class || type == Float.class || type == Long.class || type == Integer.class || type == Short.class
				|| type == Character.class || type == Byte.class || type == Boolean.class || type == String.class;
	}
}
